package xl.utils
{
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.IBitmapDrawable;
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	/**
	 * 图形工具类
	 * @author XiLing
	 */
	public class UtilsGraphics
	{
		public static function getSnapShot(obj:DisplayObject):BitmapData
		{
			var snapBitmapData:BitmapData;
			var drawableObj:IBitmapDrawable;
			var dWidth:int = obj.width;
			var dHeight:int = obj.height;
			if(obj is IBitmapDrawable)
			{
				drawableObj = obj;
			}
			else
			{
				var tmpDrawableContianer:Sprite = new Sprite();
				tmpDrawableContianer.addChild(obj);
				drawableObj = tmpDrawableContianer;
			}
			snapBitmapData = new BitmapData(dWidth,dHeight,true,0x00000000);
			snapBitmapData.draw(drawableObj);
			return snapBitmapData;
		}
	}
}